<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/5/24
 * Time: 10:52
 */
?>

<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/5/14
 * Time: 13:23
 */
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->
    <meta charset="UTF-8">
    <title>详细统计</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="author" content="evil_web（429391294@qq.com）"/>
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/popup.css"/>
    <link rel="stylesheet" href="public/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="public/css/bootstrap.css">
    <link rel="stylesheet" href="public/css/dcalendar.picker.css">
    <link rel="stylesheet" href="public/css/paging.css">
    <link rel="stylesheet" href="public/css/paging.css">
    <link rel="stylesheet" href="public/css/cqs.style.css">
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->

</head>
<body style="background-color: #f4f4f4;">
<?php $this->load->view('common/header.php'); ?>

<div class="cqs-main">
    <form method="get">
    <div class="cqs-main_top cqs-mgt30">
        数据报表：<a class="cqs-clc40000" href="javascript:;">成本中心＞</a>采购排名

        <div class="date-box">
      <span class="date-group">
          <input id='mydatepicker' name="mydatepicker"  <?php if ( isset($mydatepicker)):?> placeholder="<?php echo $mydatepicker ;?>"  <?php endif;?> type='text'/>
        <img src="img/btn_arrow_down_h.png" alt=""></span> —
            <span class="date-group">
                <input id='mydatepicker2' name="mydatepicker2" <?php if ( isset($mydatepicker2)):?> placeholder="<?php echo $mydatepicker2 ;?>"  <?php endif;?> placeholder="2018年03月27日" type='text'/>
        <img src="img/btn_arrow_down_h.png" alt=""></span>
        </div>

        <div class="cqs-search-group"><span class="cqs-img-search"><img src="img/icon_search_grey.png" alt=""></span>
            <input type="text" id="goods_id" name="goods_id" placeholder="当前条件下搜索商品ID" <?php if ( isset($goods_id)):?>value="<?php echo $goods_id ;?>"  <?php endif;?> ></div>
        <button class="cqs-output" style="float: right; margin-right: 20px;margin-top:19px;">导出报表</button>
    </div>
    </form>

    <div class="cqs-main_con table-responsive cqs-box cqs-mgb50 cqs-bgfff"><!--table table-bordered -->
        <table class="table cqs-table" style="border-bottom:1px solid #dddddd;" >
            <tr>
<!--                <th>序号</th>-->
                <th>商品ID</th>
                <th colspan="3">商品名称</th>
                <th data-field="" data-sortable="true">
                    <span class="table-name">数量</span>
                    <div class="arrow-box">
                        <span class="arrow-up up-gray"></span>
                        <span class="arrow-down down-gray"></span>
                    </div>
                </th>
                <th data-sortable="true">
                    <span class="table-name">单价(元)</span>
                    <div class="arrow-box">
                        <span class="arrow-up up-red"></span>
                        <span class="arrow-down down-gray"></span>
                    </div>
                </th>
                <th data-sortable="true">
                    <span class="table-name">小计(元)</span>
                    <div class="arrow-box">
                        <span class="arrow-up up-gray"></span>
                        <span class="arrow-down down-red"></span>
                    </div>
                </th>
            </tr>
            <?php if (isset($goods) && count($goods)):?>
                <?php foreach($goods as $key=>$or):?>
            <tr>
<!--                <td>--><?php //echo $key?><!--</td>-->
                <td><?php echo $or['product_id']?></td>
                <td><?php echo $or['product_name']?></td>
<!--                <td>颜色:--><?php //echo $or['sku_info'] ?><!--</td>-->
                <td>颜色:<?php echo $or['sku_info'] ?></td>
                <td>包装:12支/盒</td>
<!--                --><?php //foreach($or['sku_info'] as $sku_info):?>
<!--                <td>颜色:--><?php //echo $sku_info?><!--</td>-->
<!--                <td>包装:12支/盒</td>-->
<!--                --><?php //endforeach;?>
                <td><?php echo $or['sum(num)']?></td>
                <td><?php echo $or['price']?></td>
                <td><?php echo $or['sum(num*price)']?></td>
            </tr>
                <?php endforeach;?>
            <?php endif;?>
        </table>

        <div class="box" id="box"></div>
    </div>
</div>
<?php $this->load->view('common/bottom.php'); ?>

<script src="public/js/jquery.min.js"></script>
<script src="public/js/bootstrap-table.min.js"></script>
<script src="public/js/paging.min.js"></script>
<script src="public/js/dcalendar.picker.js"></script>

<script>
    var setTotalCount = 301;
    $('#box').paging({
        initPageNo: 1, // 初始页码
        totalPages: <?php echo ceil(count($goods)/2) ?>, //总页数
        totalCount: '', // 条目总数
        slideSpeed: 600, // 缓动速度。单位毫秒
        jump: true, //是否支持跳转
        callback: function (page) { // 回调函数
            console.log(page);
            var goods_id= $('#goods_id').val();
            var  mydatepicker= $('#mydatepicker').attr('placeholder');
            var mydatepicker2=$('#mydatepicker2').attr('placeholder');
            // console.log(mydatepicker);
            // console.log(mydatepicker2);
            // console.log(goods_id);
            $.ajax({
                type: "post",
                dataType: "json",
                url: "information/information_purchase_product",
                data: {'page':page,'mydatepicker':mydatepicker,'mydatepicker2':mydatepicker2,'goods_id':goods_id},
                success:function(data) {
                    console.log(data);
                    var html='';
                    //$(data.data).each(function (key, val) {
                    //html += ' <tr>';
                    //
                    //html += ' <td>'+val.product_id+'</td>';
                    //html += '  <td><?php ////echo $or['product_id']?>////</td>';
                    //html += '<td>'+val.product_name+'//</td>';
                    //html += '     <td>颜色:--><?php //////echo $or['sku_info'] ?>////<!--</td>-->';
                    //html += '    <td>颜色:'+val.sku_info+'</td>';
                    //html += '   <td>包装:12支/盒</td>';
                    //html += '    <td>'+val.num+'</td>';
                    //html += '    <td>'+val.price+'</td>';
                    //html += '    <td>'+val.price+'</td>';
                    //html += '   </tr>';
                    //})
                },
                error:function(){
                    console.log('sss')
                }


            });

        }
    });

    var _date = new Date();
    // console.log( format);
    $('#mydatepicker').dcalendarpicker({
        format: 'yyyy-MM-dd',
        defaultDate: '2',
        changeYear: true
    });
    $('#mydatepicker2').dcalendarpicker({
        format: 'yyyy-MM-dd',
        defaultDate: _date
    });
</script>
<script type="text/javascript">
    //$('.calendar').on('click',function(){
    //    var  myd= $('#mydatepicker').val(),
    //        myd2=$('#mydatepicker2').val();
    //    $('#mydatepicker').attr('placeholder',myd);
    //    $('.mydatepicker2').val(myd);
    //    $('#mydatepicker2').attr('placeholder',myd2);
    //    var admin= $('#admin').val();
    //    var account= $('#account').val();
    //    var user= $('#user').val();
    //    console.log($('#mydatepicker').val());
    //    console.log($('#mydatepicker2').val());
    //    // window.location.search = jQuery.query.set("myd", myd).set("myd2", myd2);
    //    //location.replace("<?php ////echo base_url()?>////information/information_purchase_user?ymd="+myd+"&ymd2="+myd2+"&admin="+admin+"&account="+account+"&user="+user);
    //})
</script>
</body>
</html>

